package leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author Liangyaoyun
 */
public class leetCode90 {
    public List<Integer>path=new ArrayList<>();
    public List<List<Integer>>result=new ArrayList<>();

    public List<List<Integer>>subsetsWithDup(int[] nums){
        Arrays.sort( nums );
        dfs(nums,0);
        return result;
    }
    public void dfs(int[] nums,int index){
        result.add(new ArrayList<>(path));

        for (int i = index; i < nums.length; i++) {
            if (i>index&&nums[i]==nums[i-1]){
                continue;
            }
            path.add(nums[i]);
            dfs(nums,i+1);
            path.remove(path.size()-1);
        }
    }

    public static void main(String[] args) {
        int[] nums=new  int[]{1,2,2};
        leetCode90 leetcode90=new leetCode90();
        leetcode90.subsetsWithDup(nums);
    }
}
